<template>
	<div style="text-align: left;color: black;">
		<div style="background-color: white;">
			<van-row style="padding: 1vh;">
				<div style="margin-right: 3vw;">
					<van-image @click="clickHeadEvent" width="10vw" height="10vw" fit="cover" :src="urlIp+'/'+data.user.headImgSrc" round />
				</div>
				<div style="padding: 1vh;">
					<strong style="font-size: 1rem;">
						{{data.user.userName}}
					</strong>
				</div>
			</van-row>

		</div>
		<div>
			<div v-if="data.imgSrc!==''">
				<van-image lazy-load width="100%" height="50vw" :src="urlIp+'/'+data.imgSrc" fit="cover" />
			</div>
			<h3>{{data.title}}</h3>
			<div style="height: 10vh;">{{data.context}}</div>
		</div>
		<van-button @click="accept(data)" type="primary" size="large" color="red">
			<strong>
				+{{priceShow}} &yen;
			</strong>
			立即帮忙</van-button>
	</div>

</template>

<script>
	import url from '@/assets/url.json';
	
	export default {
		props: {
			data: Object,
			accept: Function,
			openUserPage: Function
		},
		data() {
			return {
				priceShow: '',
				urlIp: url.ip
			}
		},
		mounted() {
			this.priceShow=this.priceChange(this.data.price);
		},
		
		methods: {
			clickHeadEvent(){
				if((typeof this.openUserPage)==='function'){
					this.openUserPage(this.data.uid);
				}
			},
			
			priceChange(price) {
				let str = price;
				let numberPrice = Number.parseInt(str);
				if (numberPrice < 10) {
					str = '00' + str;
				} else {
					if (numberPrice < 100) {
						str = '0' + str;
					}
				}

				let arr = str.split('');
				arr.splice(-2, 0, '.');
				str = arr.join('');
				return str;
			}
		},
	}
</script>

<style>
</style>